namespace Tools
{
    public class FileFolderHelper
    {
        /// <summary>
        /// 自动创建所需目录结构
        /// </summary>
        /// <param name="filePath">完整文件路径</param>
        /// <param name="content">文件内容</param>
        public static void CreateFileDirectory(string filePath)
        {
            try
            {
                // 获取文件所在目录路径
                string directoryPath = Path.GetDirectoryName(filePath);

                // 如果目录不存在则自动创建
                if (!string.IsNullOrEmpty(directoryPath) && !Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
}
